#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5;

int a[N + 5];
int cnt[N + 5];
int bkSum[N + 5];
int bkMult[N + 5];
int bkSumMult[N + 5];

int num = 0;
int mp[N + 5];

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(!mp[a[i]])
			mp[a[i]] = ++num;
		cnt[mp[a[i]]]++;
	}
	
	for(int i = num; i > 0; i--){
		bkSum[i] = bkSum[i + 1] + cnt[i];
		bkMult[i] = cnt[i] * bkSum[i + 1];
		bkSumMult[i] = bkSumMult[i + 1] + bkMult[i];
	}
	
	int ans = 0;
	for(int i = 1; i + 2 <= num; i++){
//		for(int j = i + 1; j < num; j++){
//			ans += cnt[i] * cnt[j] * bkSum[j + 1];
//		}
		ans += cnt[i] * bkSumMult[i + 1];
	}
	cout << ans;
	return 0;
}


